package com.hemaapp.yjnh.bean;

import java.io.Serializable;
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.android.uu.utils.uuUtils;

import xtom.frame.XtomObject;
import xtom.frame.exception.DataParseException;

/**订单列表中的简要订单信息
 * 
 */
public class Order extends XtomObject implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private String id;//	主键id	 
	private String bill_sn;//	订单号	 
	private String client_id;//	客户id
	private String pay_client_id;//	代付人id	
	private String keytype;//	订单类型	1:普通订单 2:定制订单 3:走走订单 4:代付订单
	private String confirmtype;//	预约确认结果	0待确认 1确认 2拒绝
	private String payflag;//	付款方式	1：支付宝支付 2：银联支付 3：微信支付 4：余额支付
	private String other_payflag;//代付状态	0非代付 1待确认 2接受代付 3拒绝代付
	private String tradetype;//	交易状态	0 未付款 1: 已付款待发货 2 待收货 3 已收货待评价 4 已评价交易成功
	private String sendflag;//	发货状态	0 未发货 1已发货
	private String statetype;//	订单状态	1：有效 2：已删除
	private String returnflag;//	退货状态	0：无 非0：有
	private String consignee;//收货人	
	private String phone;//收货人电话
	private String address;//收货人地址	
	private String personal_id;//预约人身份证号码	
	private String zipcode;//邮编
	private String shipping_fee;//运费
	private String total_fee;//	订单总价（含运费）
	private String goods_fee;//商品总价
	private String score_fee;// 粮票总价
	private String costcode;//消费码	
	private String memo;//备注
	private String shipping_name;//快递名称	
	private String shipping_num;//快递单号
	private String startdate;//预约开始时间
	private String regdate;//下单时间	
	private String buydate;//付款时间	
	private String senddate;//发货时间	
	private String recvdate;//收货时间
	private String seller_id;//商家/田家id
	private String expect_senddate;
	private String return_enable;//预约订单是否能退款	0否；1是
	private String addition_fee;
	private String pay_client_nickname;
    private String pay_client_username;

	private ArrayList<BillChild> childs=new ArrayList<BillChild>();

	public ArrayList<BillChild> getChildren() {
		return childs;
	}

	public void setChildren(ArrayList<BillChild> childs) {
		this.childs = childs;
	}

	public Order(JSONObject jsonObject) throws DataParseException {
		if (jsonObject != null) {
			try {
				id = get(jsonObject, "id");
				bill_sn = get(jsonObject, "bill_sn");
				client_id = get(jsonObject, "client_id");
				pay_client_id = get(jsonObject, "pay_client_id");
				keytype = get(jsonObject, "keytype");
				confirmtype = get(jsonObject, "confirmtype");
				payflag = get(jsonObject, "payflag");
				statetype = get(jsonObject, "statetype");
				returnflag = get(jsonObject, "returnflag");
				other_payflag = get(jsonObject, "other_payflag");
				tradetype = get(jsonObject, "tradetype");
				sendflag = get(jsonObject, "sendflag");
				total_fee = uuUtils.formatAfterDot2(get(jsonObject, "total_fee"));
				consignee = get(jsonObject, "consignee");
				phone = get(jsonObject, "phone");
				address = get(jsonObject, "address");
				personal_id = get(jsonObject, "personal_id");
				zipcode = get(jsonObject, "zipcode");
				shipping_fee = uuUtils.formatAfterDot2(get(jsonObject, "shipping_fee"));
				score_fee = uuUtils.formatAfterDot2(get(jsonObject, "score_fee"));
				goods_fee = uuUtils.formatAfterDot2(get(jsonObject, "goods_fee"));
				costcode = get(jsonObject, "costcode");
				memo = get(jsonObject, "memo");
				startdate = get(jsonObject, "startdate");
				shipping_name = get(jsonObject, "shipping_name");
				shipping_num = get(jsonObject, "shipping_num");
				regdate = get(jsonObject, "regdate");
				buydate = get(jsonObject, "buydate");
				senddate = get(jsonObject, "senddate");
				recvdate = get(jsonObject, "recvdate");
				seller_id = get(jsonObject, "seller_id");
				expect_senddate = get(jsonObject, "expect_senddate");
				return_enable = get(jsonObject, "return_enable");
                addition_fee = uuUtils.formatAfterDot2(get(jsonObject, "addition_fee"));
                pay_client_nickname = get(jsonObject, "pay_client_nickname");
                pay_client_username = get(jsonObject, "pay_client_username");

				if (!jsonObject.isNull("childItems")
						&& !isNull(jsonObject.getString("childItems"))) {
					JSONArray gObj = jsonObject.getJSONArray("childItems");
					for (int i = 0; i < gObj.length(); i++) {
						childs.add(new BillChild((JSONObject) gObj.get(i)));
					}
				}
			} catch (JSONException e) {
				throw new DataParseException(e);
			}
		}
	}

    public String getExpect_senddate() {
        return expect_senddate;
    }

    public String getId() {
		return id;
	}
	
	public String getBill_sn() {
		return bill_sn;
	}

	public String getClient_id() {
		return client_id;
	}

	public String getPay_client_id() {
		return pay_client_id;
	}

	public String getKeytype() {
		return keytype;
	}

	public String getConfirmtype() {
		return confirmtype;
	}

	public String getPayflag() {
		return payflag;
	}

	public String getOther_payflag() {
		return other_payflag;
	}

	public String getTradetype() {
		return tradetype;
	}

	public String getSendflag() {
		return sendflag;
	}

	public String getStatetype() {
		return statetype;
	}

	public String getReturnflag() {
		return returnflag;
	}

	public String getTotal_fee() {
		return total_fee;
	}

	public String getGoods_fee() {
		return goods_fee;
	}

	public String getConsignee() {
		return consignee;
	}

	public String getPhone() {
		return phone;
	}

	public String getAddress() {
		return address;
	}

	public String getPersonal_id() {
		return personal_id;
	}

	public String getZipcode() {
		return zipcode;
	}

	public String getShipping_fee() {
		return shipping_fee;
	}

	public String getCostcode() {
		return costcode;
	}

	public String getMemo() {
		return memo;
	}

	public String getStartdate() {
		return startdate;
	}

	public String getShipping_name() {
		return shipping_name;
	}

	public String getScore_fee() {
		return score_fee;
	}

	public String getShipping_num() {
		return shipping_num;
	}

	public String getRegdate() {
		return regdate;
	}

	public String getBuydate() {
		return buydate;
	}

    public String getAddition_fee() {
        return addition_fee;
    }

    public String getSenddate() {
		return senddate;
	}

	public String getRecvdate() {
		return recvdate;
	}

	public String getSeller_id() {
		return seller_id;
	}

	public String getReturn_enable() {
		return return_enable;
	}

    public String getPay_client_username() {
        return pay_client_username;
    }

    public String getPay_client_nickname() {
        return pay_client_nickname;
    }

    public class BillChild extends XtomObject implements Serializable{
		//childItems中的参数
		private String id;//订单货品id
		private String blog_id;//商品id	
		private String seller_id;//卖家id
		private String client_id;//用户id	
		private String reply_id;//回复主键	
		private String name;//商品名称	
		private String price;//单价	
		private String buycount;//购买数量	
		private String imgurl;//商品图片	
		private String imgurlbig;//商品大图	
		private String blog_returnflag;//	允许退货标记	0不允许 1允许
		private String days;//走走天数
		private String bill_id;//订单id	
		private String bill_sn;//订单编号	
		private String regdate;//下单时间	
		private String expressfee;//下单时，单个商品运费	
		private String shipping_fee;//该商品实际运费	
		private String itemtype;//状态	0正常 1申请中 2等待买家发货 3拒绝 4退货中 5退货完成
		private String servicetype;//退换货	0 无 1 退货 2 换货 3 维修
		private String replytype;//评价状态	0 未评论 1 已评价
		private String applydate;//申请售后时间	
		private String reason;//申请原因	
		private String description;//原因说明	
		private String handledate;//处理时间	
		private String memo;//处理说明	
		private String imgurl0;//第一张退换货的小图	
		private String imgurl0big;//第一张退换货的小图	
		private String imgurl1;//第2张退换货的小图	
		private String imgurl1big;//第2张退换货的小图	
		private String imgurl2;//第3张退换货的小图	
		private String imgurl2big;//第3张退换货的小图	
		private String imgurl3;//第4张退换货的小图	
		private String imgurl3big;//第4张退换货的小图
		private String type;//商品类型：
		//0唠嗑帖子；1田家农货；2有机；3地标；4村游；5田家日志；6特产；9乐乐；11粮库；
		//71走走房车露营；72走走自驾车露营；73走走帐篷露营；74走走商品区；75走走房车；
		//81苗木；82花卉；83家电；84日用品；10众农
        private String one_spec;//一级规格名称
        private String one_specname;//一级规格内容
        private String two_spec;//二级规格名称
        private String two_specname;//二级规格内容

		public BillChild(JSONObject jsonObject) throws DataParseException {
			if (jsonObject != null) {
				try {
					id = get(jsonObject, "id");
					blog_id = get(jsonObject, "blog_id");
					seller_id = get(jsonObject, "seller_id");
					client_id = get(jsonObject, "client_id");
					reply_id = get(jsonObject, "reply_id");
					name = get(jsonObject, "name");
					price = uuUtils.formatAfterDot2(get(jsonObject, "price"));
					buycount = get(jsonObject, "buycount");
					imgurlbig = get(jsonObject, "imgurlbig");
					blog_returnflag = get(jsonObject, "blog_returnflag");
					days = get(jsonObject, "days");
					imgurl = get(jsonObject, "imgurl");
					bill_id = get(jsonObject, "bill_id");
					bill_sn = get(jsonObject, "bill_sn");
					regdate = get(jsonObject, "regdate");
					expressfee = uuUtils.formatAfterDot2(get(jsonObject, "expressfee"));
					shipping_fee = uuUtils.formatAfterDot2(get(jsonObject, "shipping_fee"));
					itemtype = get(jsonObject, "itemtype");
					servicetype = get(jsonObject, "servicetype");
					replytype = get(jsonObject, "replytype");
					applydate = get(jsonObject, "applydate");
					reason = get(jsonObject, "reason");
					description = get(jsonObject, "description");
					handledate = get(jsonObject, "handledate");
					memo = get(jsonObject, "memo");
					imgurl0 = get(jsonObject, "imgurl0");
					imgurl0big = get(jsonObject, "imgurl0big");
					imgurl1 = get(jsonObject, "imgurl1");
					imgurl1big = get(jsonObject, "imgurl1big");
					imgurl2 = get(jsonObject, "imgurl2");
					imgurl2big = get(jsonObject, "imgurl2big");
					imgurl3 = get(jsonObject, "imgurl3");
					imgurl3big = get(jsonObject, "imgurl3big");
					type = get(jsonObject, "type");
                    one_spec = get(jsonObject, "one_spec");
                    one_specname = get(jsonObject, "one_specname");
                    two_spec = get(jsonObject, "two_spec");
                    two_specname = get(jsonObject, "two_specname");

                    log_i(toString());
				} catch (JSONException e) {
					throw new DataParseException(e);
				}
			}
		}

        public String getOne_spec() {
            return one_spec;
        }

        public String getOne_specname() {
            return one_specname;
        }

        public String getTwo_spec() {
            return two_spec;
        }

        public String getTwo_specname() {
            return two_specname;
        }

        public String getId() {
			return id;
		}

		public String getBlog_id() {
			return blog_id;
		}

		public String getSeller_id() {
			return seller_id;
		}

		public String getClient_id() {
			return client_id;
		}

		public String getReply_id() {
			return reply_id;
		}

		public String getName() {
			return name;
		}

		public String getPrice() {
			return price;
		}

		public String getBuycount() {
			return buycount;
		}

		public String getImgurl() {
			return imgurl;
		}

		public String getImgurlbig() {
			return imgurlbig;
		}

		public String getBlogReturnflag() {
			return blog_returnflag;
		}

		public String getDays() {
			return days;
		}

		public String getBill_id() {
			return bill_id;
		}

		public String getBill_sn() {
			return bill_sn;
		}

		public String getRegdate() {
			return regdate;
		}

		public String getExpressfee() {
			return expressfee;
		}

		public String getShipping_fee() {
			return shipping_fee;
		}

		public String getItemtype() {
			return itemtype;
		}

		public String getServicetype() {
			return servicetype;
		}

		public String getReplytype() {
			return replytype;
		}

		public String getApplydate() {
			return applydate;
		}

		public String getReason() {
			return reason;
		}

		public String getDescription() {
			return description;
		}

		public String getHandledate() {
			return handledate;
		}

		public String getMemo() {
			return memo;
		}

		public String getImgurl0() {
			return imgurl0;
		}

		public String getImgurl0big() {
			return imgurl0big;
		}

		public String getImgurl1() {
			return imgurl1;
		}

		public String getImgurl1big() {
			return imgurl1big;
		}

		public String getImgurl2() {
			return imgurl2;
		}

		public String getImgurl2big() {
			return imgurl2big;
		}

		public String getImgurl3() {
			return imgurl3;
		}

		public String getImgurl3big() {
			return imgurl3big;
		}

		public String getType() {
			return type;
		}
	}
}
